layui.config({
  base: '/' //假设这是你存放拓展模块的根目录
}).extend({ //设定模块别名
  murl: 'url' //如果 mymod.js 是在根目录，也可以不用设定别名
});
layui.use(['form','murl','layer','element','laydate','laytpl'], function () {
     var laydate = layui.laydate,laytpl = layui.laytpl ,form = layui.form, murl=layui.murl,id = murl.get("id");
     var layerTips = parent.layer === undefined ? layui.layer : parent.layer;
      $.ajax({
         url: '/api_account_log/txInfo?id='+id,
         type: 'get',
         dataType: "json",
         success: function (data) {
             if(data.rel){
               setLabelValues(data.result);
               setInputValues(data.result);
             }
         }
       });

      $("#zcCount").blur(function () {
       if($(this).val()==""){
              layerTips.msg('提现金额不能为空');
              $("#zcCount").val("");
             return;
       }


      });




    form.on('submit(save)', function(data){

        submitForm(data);
       return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
     });

     form.on('submit(cancel)', function(data){

        if($("#notes").val()==""){
           layerTips.msg('请填写备注');
           return false;
         }
        layer.confirm('确定退回吗？', null, function (index) {
            submitFailForm(data);
          });

        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
      });
});

function submitForm(data){
  $.ajax({
     url: '/api_account/txsuc',
     type: 'post',
     data: data.field,
     dataType: "json",
     success: function (data) {
         var layerTips = parent.layer === undefined ? layui.layer : parent.layer;
         if(data.rel){
            layerTips.msg('处理成功');
             window.setTimeout(function () {
                         parent.tab.deleteTab(parent.tab.getCurrentTabId(),true);
                     },1000);
         }else{
           layerTips.msg(data.msg);
         }
     }
   });
}
function submitFailForm(data){
  $.ajax({
     url: '/api_account/txfail',
     type: 'post',
     data: data.field,
     dataType: "json",
     success: function (data) {
         var layerTips = parent.layer === undefined ? layui.layer : parent.layer;
         if(data.rel){
            layerTips.msg('处理成功');
             window.setTimeout(function () {
                         parent.tab.deleteTab(parent.tab.getCurrentTabId(),true);
                     },1000);
         }else{
           layerTips.msg(data.msg);
         }
     }
   });
}

function setLabelValues(data) {
    for (var p in data) {
        $("#" + p + "").html(data[p]);
    }
}

function setInputValues(data) {
    for (var p in data) {
        $("#" + p + "").val(data[p]);
    }
}